{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    {include file='public:left-menu'/}
    <!--End 左侧导航-->
    <!--头部信息-->
    {include file='public:nav-header' title="会员管理" subTitle="添加编辑钱包"/}
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                <form method="post" id="submit-form" class="row">
                  <div class="form-group col-md-12">
                    <div class="row">
                      <div class="col-md-6">
                        <label class="form-title"><em class="require">*</em>钱包名称</label>
                        <input type="text" class="form-control" name="name" value="{$info.name}" placeholder="请输入钱包名称"/>
                        <span class="help">钱包必要名称</span>
                        <span class="error" id="err_name"></span>
                      </div>
                      <div class="col-md-6">
                        <label class="form-title"><em class="require">*</em>补贴比例</label>
                        <input type="text" class="form-control" name="bt_bl" value="{$info.bt_bl}" placeholder="请输入补贴比例"/>
                        <span class="help">钱包补贴比例</span>
                        <span class="error" id="err_bt_bl"></span>
                      </div>
                    </div>
                  </div>
                  <div class="form-group col-md-12">
                    <div class="row">
                      <div class="col-md-3">
                        <label class="form-title"><em class="require">*</em>最小转赠</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="g_min" value="{$info.g_min}" placeholder="请输入最小转赠金额"/>
                              <span class="input-group-addon">元</span>
                          </div>
                        <span class="help">钱包最小转赠金额</span>
                        <span class="error" id="err_g_min"></span>
                      </div>
                      <div class="col-md-3">
                        <label class="form-title"><em class="require">*</em>最大转赠</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="g_max" value="{$info.g_max}" placeholder="请输入最大转赠金额"/>
                              <span class="input-group-addon">元</span>
                          </div>
                        <span class="help">钱包最大转赠金额</span>
                        <span class="error" id="err_g_max"></span>
                      </div>
                      <div class="col-md-3">
                        <label class="form-title"><em class="require">*</em>转赠系数</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="g_xishu" value="{$info.g_xishu}" placeholder="请输入转赠金额系数"/>
                              <span class="input-group-addon">元</span>
                          </div>
                        <span class="help">钱包转赠金额系数</span>
                        <span class="error" id="err_g_xishu"></span>
                      </div>
                      <div class="col-md-3">
                        <label class="form-title"><em class="require">*</em>转赠手续费</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="g_sxf" value="{$info.g_sxf}" placeholder="请输入转赠手续费"/>
                              <span class="input-group-addon">%</span>
                          </div>
                        <span class="help">钱包转赠手续费</span>
                        <span class="error" id="err_g_sxf"></span>
                      </div>
                    </div>
                  </div>
                  <div class="form-group col-md-12">
                    <div class="row">
                      <div class="col-md-4">
                        <label class="form-title"><em class="require">*</em>最小交易</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="jy_min" value="{$info.jy_min}" placeholder="请输入最小交易金额"/>
                              <span class="input-group-addon">元</span>
                          </div>
                        <span class="help">钱包最小交易金额</span>
                        <span class="error" id="err_jy_min"></span>
                      </div>
                      <div class="col-md-4">
                        <label class="form-title"><em class="require">*</em>交易手续费</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="jy_sxf" value="{$info.jy_sxf}" placeholder="请输入交易手续费"/>
                              <span class="input-group-addon">%</span>
                          </div>
                        <span class="help">钱包交易手续费</span>
                        <span class="error" id="err_jy_sxf"></span>
                      </div>
                      <div class="col-md-4">
                        <label class="form-title"><em class="require">*</em>交易价格</label>
                          <div class="input-group">
                              <input type="text" class="form-control" name="jy_price" value="{$info.jy_price}" placeholder="请输入交易价格"/>
                              <span class="input-group-addon">元</span>
                          </div>
                        <span class="help">钱包交易价格</span>
                        <span class="error" id="err_jy_price"></span>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-12">
                    <input type="hidden" name="{$info.pk}" value="{$info[$info.pk]}">
                    <button type="button" class="btn-theme submit-btn">确定</button>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<style>
    .control{
        display: flex;
        align-items: center;
        min-height: 38px;
    }
    .control input{
        border:1px solid #ebebeb;
        border-radius: 2px;
        width: 200px;
        height: 38px;
    }
</style>
<script type="text/javascript">
  $(function(){
    $('.submit-btn').click(function () {
      $('span.error').hide();
      $('span.error').parent().removeClass('has-error');
      var url = "{:url('User/add_edit_wallet')}";
      var data = $('#submit-form').serialize();
      $.ajax({
        type: "POST",
        url: url,
        data: data,
        dataType: 'json',
        success: function (data) {
          if (data.code == 1) {
            showSuccessMsg(data.msg, function () {
              if (data.data.url) {
                location.href = data.data.url;
              }
            });
          } else if (data.code == 10) {
              showErrorMsg(data.msg);
            $.each(data.data.result, function(index, item) {
              $('#err_' + index).text(item).show();
              $('#err_' + index).parent().addClass('has-error');
            });
          } else {
            showErrorMsg(data.msg);
          }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            showErrorMsg("网络失败，请刷新后重试!");
        }
      });
    });
  });
  function call_back(fileurl_tmp,fileurl_id)
  {
    $("[name="+fileurl_id+"]").val(fileurl_tmp);
    $("#"+fileurl_id).attr('src', fileurl_tmp);
  }
</script>
</body>
</html>
